package com.itheima.aliyunosstest.controller;

import com.itheima.aliyunosstest.pojo.Result;
import com.itheima.aliyunosstest.utils.AliyunOssOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class UploadController {
    @Autowired
    private AliyunOssOperator aliyunOssOperator;

    @PostMapping("/upload")
    public Result upload(MultipartFile  file,String name) throws Exception {
        System.out.println( name);
        aliyunOssOperator.upload(file.getOriginalFilename(),file.getBytes());
        return Result.success();
    }
}
